import Layout from '@/layout'
import BlankTemplate from '@/layout/components/BlankTemplate'

/**
 * Custom route configs: (basic fields: https://router.vuejs.org/api/#routes)
 *  <Field>: <Default>    <Detail>
 *  meta: {
 *    title:              The name show in nav-menu, recommend to set.
 *    icon:               The icon show in nav-menu.
 *    noCache: false      If set true, page will not be cached.
 *    showInNavMenu: false
 *    navMenuRoot: false  If set true, children will show in nav-menu.
 *                        If more than one is set, only the first one is valid.
 *    pinToTagView: false Pin to tag-views and not closable.
 *  }
 *
 * TODO@huanglf: 规则说明补充...
 */

export const dynamicRoutes = [
  { path: '/sys', name: 'System', component: BlankTemplate,
    meta: { title: '系统', icon: 'el-icon-s-platform', showInNavMenu: true },
    children: [
      { path: 'list', name: 'UserList', component: BlankTemplate,
        meta: { title: '用户列表', icon: 'el-icon-s-order', showInNavMenu: true },
        children: [
          { path: 'create', name: 'CreateUser',
            component: () => import('@/views/system'),
            meta: { title: '新建用户----长标题', icon: 'el-icon-circle-plus', showInNavMenu: true }
          }
        ]
      }
    ]
  },
  { path: '/maintain', name: 'Maintain',
    component: () => import('@/views/maintain'),
    meta: { title: '运维', icon: 'el-icon-s-flag', showInNavMenu: true }
  },
  { path: '/proj', name: 'Project', component: BlankTemplate,
    meta: { title: '工程', icon: 'el-icon-s-management', showInNavMenu: true },
    children: [
      { path: 'list', name: 'ProjectList', component: BlankTemplate,
        meta: { title: '工程列表', icon: 'el-icon-s-order', showInNavMenu: true },
        children: [
          { path: 'create', name: 'CreateProject',
            component: () => import('@/views/project'),
            meta: { title: '新建工程', icon: 'el-icon-circle-plus', showInNavMenu: true }
          }
        ]
      }
    ]
  }
]

export const routes = [
  { path: '/', alias: '/home', redirect: '/home', component: Layout,
    meta: { navMenuRoot: true },
    children: [
      { path: 'home', name: 'Home',
        component: () => import('@/views'),
        meta: { title: '首页', icon: 'el-icon-s-home', showInNavMenu: true,
          pinToTagView: true }
      },
      ...dynamicRoutes // TODO@huanglf: for test
    ]
  },

  { path: '/login', name: 'Login', component: () => import('@/views/login') },

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/login' }
]

